package com.example.nacosdiscovery;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;

import javax.annotation.PostConstruct;

@EnableDiscoveryClient
@SpringBootApplication
public class NacosdiscoveryApplication {
    /**
     * @Value("${spring.cloud.nacos.config.server-addr}") //无法读取到bootstrap文件里面的
     * private String addr;
     * public static String addr1;
     * @PostConstruct private void getEnvironment() {
     * addr1=this.addr;
     * }
     */
    @Value("${server.port}")
    private Integer port;
    public static Integer port1;

    @PostConstruct
    private void getEnvironment() {
        port1 = this.port;
    }

    public static void main(String[] args) {
        SpringApplication.run(NacosdiscoveryApplication.class, args);
        while (true) {
            System.out.println("nacosdiscovery正在运行" + "port" + port1);
        }
    }

}
